Imports System.Diagnostics.ProcessStartInfo
Imports System.Net
Public Class IPInfo
    Private C_PhysicalAddress As String
    Private C_DHCPEnabled As String
    Private C_IPAddress As String
    Private C_SubnetMask As String
    Private C_DefaultGateway As String
    Private C_DHCPServer As String
    Private C_DNSServer As String
    Private C_PrimaryWINSServer As String
    Public Sub New()
        getinfo()
    End Sub
    Public ReadOnly Property IPAddress() As String
        Get
            Return C_IPAddress
        End Get
    End Property
    Public ReadOnly Property SubnetMask() As String
        Get
            Return C_SubnetMask
        End Get
    End Property
    Public ReadOnly Property DefaultGateway() As String
        Get
            Return C_DefaultGateway
        End Get
    End Property
    Public ReadOnly Property DNSServer() As String
        Get
            Return C_DNSServer
        End Get
    End Property
    Public Sub GetInfo()
        Dim myProcess As New Process
        Dim myProcessStartInfo As New System.Diagnostics.ProcessStartInfo("ipconfig", "/all")
        myProcessStartInfo.UseShellExecute = False
        myProcessStartInfo.RedirectStandardOutput = True
        myProcess.StartInfo = myProcessStartInfo
        myProcessStartInfo.CreateNoWindow = True
        myProcess.Start()
        Dim InputData As String
        Dim StreamReader As System.IO.StreamReader = myProcess.StandardOutput
        Do Until StreamReader.EndOfStream
            InputData = StreamReader.ReadLine
            If InStr(InputData, "Physical Address") > 0 Then
                C_PhysicalAddress = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            ElseIf InStr(InputData, "Dhcp Enabled") > 0 Then
                C_DHCPEnabled = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            ElseIf InStr(InputData, "IP Address") > 0 Then
                C_IPAddress = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            ElseIf InStr(InputData, "Subnet Mask") > 0 Then
                C_SubnetMask = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            ElseIf InStr(InputData, "Default Gateway") > 0 Then
                C_DefaultGateway = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            ElseIf InStr(InputData, "DHCP Server") > 0 Then
                C_DHCPServer = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            ElseIf InStr(InputData, "DNS Server") > 0 Then
                C_DNSServer = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            ElseIf InStr(InputData, "Primary WINS Server") > 0 Then
                C_PrimaryWINSServer = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
            End If
            'Win 7
            If InStr(InputData, "IPv4 Address") > 0 Then
                Dim Temp As String = Trim(Mid(InputData, (InStr(InputData, ":") + 1)))
                C_IPAddress = Temp.Substring(0, Temp.IndexOf("("))
            End If

        Loop
        StreamReader.Close()
    End Sub
End Class
